package com.smx.steppingstone;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.smx.firetag.TemplateMolder;
import com.smx.steppingstone.renderer.HtmlRenderer;
import com.smx.steppingstone.sm.Address;
import com.smx.steppingstone.sm.Customer;
import com.smx.steppingstone.visitors.XMLVisitor;

public class Analyser {

	public static void main(String[] arg) {
		Customer cust = new Customer();
		cust.setAge(4);
		cust.setName("Satans little layer");


		List<Address> list = new ArrayList<Address>();
		Address a1 = new Address();
		a1.setAddress1("A1 One");
		a1.setAddress2("A1 Two");

		list.add(a1);

		cust.setAddressList(list);

		/*

		Customer cust = new Customer();
		cust.setAge(4);
		cust.setName("Satans little layer");
		List<Address> list = new ArrayList<Address>();
		Address a1 = new Address();
		a1.setAddress1("A1 One");
		a1.setAddress2("A1 Two");

		Customer possible1 = new Customer();
		possible1.setName("Possible 1");
		possible3.setScore(4334.3f);
		possible3.setAge(210);

		Customer possible2 =new Customer();
		possible2.setName("Possible 2");

		Customer possible3 =new Customer();
		possible3.setName("Possible 3");
		possible3.setScore(3.3f);
		possible3.setAge(20);

		List<Customer> possibleCustomerList=new ArrayList<Customer>();
		possibleCustomerList.add (possible1);
		possibleCustomerList.add (possible2);
		possibleCustomerList.add (possible3);

		a1.setPossibleCustomers(possibleCustomerList);

		list.add(a1);

		Address a2 = new Address();
		a2.setAddress1("A2 One");
		a2.setAddress2("A2 Two");


		Address a2Temp = new Address();
		a2Temp.setAddress1("a2Temp One");
		a2Temp.setAddress2("a2Temp Two");
		a2.setTempAddress(a2Temp);

		list.add(a2);

		List<Info> infoList=new ArrayList<Info>();
		Info i1=new Info();
		i1.setInfo("Sampel infor");

		Info i2=new Info();
		i2.setInfo("Sampel inforation B");

		HashMap<String,Integer> infomap=new HashMap<String,Integer>();
		infomap.put("key1", 1);
		infomap.put("key2", 2);
		infomap.put("key3", 3);
		i1.setInfomap(infomap);

		HashMap<String,String> moreInfo=new HashMap<String,String>();
		moreInfo.put("key1moreInfo", "moreInfo");
		moreInfo.put("key2moreInfo", "moreInfo2");
		moreInfo.put("key3moreInfo", "moreInfo3");

		i1.setMoreInfo(moreInfo);

		infoList.add(i1);
		infoList.add(i2);

		cust.setInfoList(infoList);
		cust.setAddressList(list);

		 */

		Address a2 = new Address();
		a2.setAddress1("A2 One");
		a2.setAddress2("A2 Two");


		Address a2Temp = new Address();
		a2Temp.setAddress1("a2Temp One");
		a2Temp.setAddress2("a2Temp Two");
		a2.setTempAddress(a2Temp);

		Address[] arr=new Address[2];
		arr[0]=a1;
		arr[1]=a2;

		XMLVisitor visitor = new XMLVisitor();
		visitor.visit( a1  );
		InputStream stream =null;
		try {
			StringBuffer buff = visitor.getBuffer();
			System.out.print(buff);
			HtmlRenderer renderer=new HtmlRenderer();
			renderer.render(buff);			
	
			System.out.println(renderer.getBuffer());
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(stream != null){
				try {
					stream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}

	}

}
